home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 56804 / 56804.xpi / chrome / content / alexaRestrictions.js < prev    next >
Encoding:
Text File  |  2010-01-31  |  2.0 KB  |  64 lines

  1. if(!com) var com={};
  2. if(!com.seostatus) com.seostatus={};
  3.  
  4. com.seostatus.alexaRestrictions =  function(){
  5.   var pub = {};
  6.   pub.pref = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
  7.   
  8.   pub.addPrivateSite = function()
  9.     {
  10.         var dlg = window.openDialog('chrome://seostatus/content/alexaRestrictedSites.xul', 'stb-addAlexaRestrictedSite-dialog', 'centerscreen,chrome,modal');
  11.     }
  12.   
  13.   pub.deletePrivateSite = function()
  14.   {
  15.     var sitelist = document.getElementById( "stb-privatesitelist");
  16.       var index = sitelist.selectedIndex;
  17.       if( index > -1 )
  18.       {
  19.           sitelist.removeItemAt( index );
  20.       }
  21.   }
  22.   
  23.   pub.loadAllRestrictedSites = function(){
  24.   
  25.       var branch = pub.pref.getBranch("seostatus.");
  26.           try 
  27.           {
  28.             if(branch.prefHasUserValue("stb_alexa_restricted_total_num")){
  29.                 var numSites = branch.getIntPref("stb_alexa_restricted_total_num");
  30.             //alert(numSites);             
  31.                for (var i=0; i < numSites; i++){
  32.                         var aSite = branch.getCharPref("stb_alexa_restricted_sites["+i+"]");          
  33.                         document.getElementById( 'stb-privatesitelist' ).appendItem(aSite);      
  34.               }
  35.         }
  36.           }
  37.           catch(e)
  38.           {
  39.             //alert("error: " + e);
  40.           }
  41.   }
  42.   
  43.   pub.setRestrictedSites = function(){
  44.       var branch = pub.pref.getBranch("seostatus.");
  45.       
  46.         try{
  47.           var theSites = document.getElementById("stb-privatesitelist");
  48.           var numSites = theSites.getRowCount();
  49.           //alert("numSites: " + numSites);
  50.           branch.setIntPref("stb_alexa_restricted_total_num", numSites);
  51.   
  52.           for (var i=0; i < numSites; i++){
  53.             branch.setCharPref("stb_alexa_restricted_sites["+i+"]", theSites.getItemAtIndex(i).label);
  54.             //  alert(theSites.getItemAtIndex(i).label);
  55.           }
  56.         }
  57.     catch(e){ 
  58.         //alert("error: " + e);
  59.     }
  60.     
  61.   }
  62.   return pub;
  63. }();
  64.